package promote.brozen.spring.event;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ApplicationEventMulticaster;
import org.springframework.context.event.SimpleApplicationEventMulticaster;

import java.util.concurrent.Executors;

/**
 * @author Brozen
 * @date 2020/9/1 8:29 AM
 * @email brozen@qq.com
 */
@Configuration
@ComponentScan(basePackageClasses = EventTest.class)
public class EventTest {

    public static void main(String[] args) {
        new AnnotationConfigApplicationContext(EventTest.class);
    }

    @Bean
    public ApplicationEventMulticaster applicationEventMulticaster() {
        SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();
        eventMulticaster.setTaskExecutor(Executors.newSingleThreadExecutor());
        return eventMulticaster;
    }

}
